/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.ws.modelo;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;


@Entity
@NamedQueries({
    @NamedQuery(name = "Pagina.listar", query = "SELECT p FROM Pagina p"),
    @NamedQuery(name = "Pagina.listaPaginas", query = "SELECT p FROM Pagina p WHERE p.modulo = null"),
    @NamedQuery(name = "Pagina.consultarPorNome", query = "SELECT p FROM Pagina p WHERE p.nome = :nome"),
})
public class Pagina {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private int codigo;
    private String nome;

    @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST,CascadeType.MERGE,CascadeType.REFRESH})
    @JoinColumn(name="modulocodigo")
    private Modulo modulo;

    public Modulo getModulo() {
        return modulo;
    }

    public void setModulo(Modulo modulo) {
        this.modulo = modulo;
    }

    public int getCodigo() {
        return codigo;
    }

    public void setCodigo(int codigo) {
        this.codigo = codigo;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }
}
